package com.citybox.domain.wx;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class WechatUserInfoDo {

    @JsonProperty("openId")
    private String openId;

    @JsonProperty("nickName")
    private String nickName;

    @JsonProperty("unionId")
    private String unionId;

    @JsonProperty("watermark")
    private Watermark watermark;

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Watermark {
        @JsonProperty("appid")
        private String appid;

        @JsonProperty("timestamp")
        private Long timestamp;
    }

    public boolean isValid(String appid) {
        return watermark != null && appid.equals(watermark.getAppid());
    }

}
